﻿<?php
require_once('../../config.php');
define('AJAX_SCRIPT', true);
$cssdir =  $CFG->wwwroot.'/local/myplugin/mycss.css';
echo '<link rel="stylesheet" href="'.$cssdir.'" type="text/css" media="screen" />';
global $DB;

$q=$_GET["q"];
// neu dung sql thi phai co mdl_ truoc ten bang, con dung get_record
$sql="SELECT * FROM mdl_subject WHERE bodyofknowledge = '".$q."'";
$rs = $DB->get_records_sql($sql);

echo html_writer::tag('div', 'Danh mục các môn học có trong khối kiến thức '.$q);
echo html_writer::start_tag('table',array('border'=>'1'));
echo html_writer::tag('th', 'Mã môn học', array('style'=>'border: 1px solid black;'));
echo html_writer::tag('th', 'Tên tiếng Anh', array('style'=>'border: 1px solid black;'));
echo html_writer::tag('th', 'Tên tiếng Việt', array('style'=>'border: 1px solid black;'));
echo html_writer::tag('th', 'Số tín chỉ', array('style'=>'border: 1px solid black;'));
echo html_writer::tag('th', 'Số giờ lý thuyết', array('style'=>'border: 1px solid black;'));
echo html_writer::tag('th', 'Số giờ thực hành', array('style'=>'border: 1px solid black;'));

foreach ($rs as $r) {
	echo html_writer::start_tag('tr', array('border'=>'2', 'class'=>'block'));
	echo html_writer::tag('td', $r->subject_id, array('style'=>'border: 1px solid black;'));
	echo html_writer::tag('td', $r->subject_name_en, array('style'=>'border: 1px solid black;'));
	echo html_writer::tag('td', $r->subject_name_vn, array('style'=>'border: 1px solid black;'));
	echo html_writer::tag('td', $r->subject_credit, array('style'=>'border: 1px solid black;'));
	echo html_writer::tag('td', $r->subject_theory_hr, array('style'=>'border: 1px solid black;'));
	echo html_writer::tag('td', $r->subject_practice_hr, array('style'=>'border: 1px solid black;'));
	echo html_writer::end_tag('tr');
}
echo html_writer::end_tag('table');